const mongoose = require("mongoose")
const bcrypt = require("bcryptjs")
const { Schema, model } = mongoose
const UserSchema = new Schema({
    username: {
        type: String,
        required: [true, "username 是必须的"],
    },
    password: {
        type: String,
        select: false,
        required: [true, "password 是必须的"],
        set(val) {
            return bcrypt.hashSync(val, 10)
        }
    }
})

const AdminUser = model("AdminUser", UserSchema)
module.exports = AdminUser